﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace G28BS.GameModels
{
    public class FimbulfambQueries
    {
        private IFimbulfambRepository repo = null;

        public FimbulfambQueries()
        {
            repo = new FimbulfambRepository();
        }

        public FimbulfambQueries(IFimbulfambRepository r)
        {
            repo = r;
        }

        public IEnumerable<int> GetShuffledWordIDs()
        {
            IEnumerable<int> wIDs = (from w in repo.FimbulfambWords
                                     select w.fimbulfambWordID);
            Random random = new Random();
            int seed = random.Next();
            wIDs = wIDs.OrderBy(w => (~(w & seed)) & (w | seed));
            return wIDs;                   
        }

        public FimbulfambWord GetWordByID(int id)
        {
            return (from w in repo.FimbulfambWords
                    where w.fimbulfambWordID == id
                    select w).SingleOrDefault();
        }
    }
}